package com.lagou.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

//@Controller
@RestController //组合注解 组合@Controller+@ResponseBody
@RequestMapping("/restful")
public class RestfulController {

    //根据id进行查询
    //@RequestMapping(value = "/user/{id}",method = RequestMethod.GET)
    //@ResponseBody
    @GetMapping("/user/{id}") //替换掉@RequestMapping(value = "/user/{id}",method = RequestMethod.GET)
    public String findById(@PathVariable Integer id){
        //调用service方法完成对id为2的这条记录的查询
        //findById中怎么样才能获取到restful编程风格中url里面占位符的值
        return "findById"+id;
    }

    //新增方法
    @PostMapping("/user") //替换掉@RequestMapping(value = "/user",method = RequestMethod.POST)
    public String post(){
        //新增
        return "post";
    }

    //更新方法
    @PutMapping("/user")
    public String put(){
        //更新操作
        return "put";
    }

    //删除方法
    @DeleteMapping("/user/{id}")
    public String delete(@PathVariable Integer id){
        //删除操作
        return "delete";
    }
}
